import { defineStore } from 'pinia'

const useUserStore = defineStore('user', {
    state() {
        return {
            num: 10,
            userInfo: {},
            foodList: []
        }
    },
    getters: {
        dubbleNum: (state) => {
            return state.num * 2
        }
    },

    actions: {
        add() {
            this.num++;
            
        },
        additem(value){
            this.foodList.unshift(value)
        },
        async login(state, payload) {
            // const {data} = await request.get('/user/login',{username,password})
            this.userInfo = { username: 'laoxie', password: 123 };
        },

    },

})

export default useUserStore

// const userStore = useUserStore()
// 访问
// userStore.num;
// userStore.dubbleNum;
// 修改
// userStore.num++;
// userStore.add();